<script>
  setTimeout(() => {
  	// #1
    new Promise(resolve => {
      resolve();
    }).then(() => {
    	// #6
      console.log('test');
    });

    console.log(4);
  });

  new Promise(resolve => {
    resolve();
    console.log(1)
  }).then(() => {
  	// #2
    console.log(3);
    Promise.resolve().then(() => {
    	// #3 走这儿的时候确确实实打印了 before timeout
    	// 但同时又产生了一个微任务
      console.log('before timeout');
      // return undefined
      // return Promise.resolve(undefined)
    }).then(() => {
    	// #4
      Promise.resolve().then(() => {
      	// #5
        console.log('also before timeout')
      })
    })
  })
  console.log(2);
</script>